package com.tinem.platform.module.starter.web.config;

import com.tinem.platform.module.starter.web.context.GatewayContext;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @author fengzhihao
 * @version v1
 * @program: platform
 * @className GateWayConfig
 * @description TODO
 * @site 
 * @company 
 * @create 2020-07-04 14:48
 */
@Configuration
public class ApplicationContext {
    public static ConfigurableApplicationContext applicationContext;
    @Bean
    public ApplicationListener<ApplicationReadyEvent> start(){
        return (applicationReadyEvent)->{
            applicationContext = applicationReadyEvent.getApplicationContext();
            GatewayContext.stringRedisTemplate = applicationReadyEvent.getApplicationContext().getBean(StringRedisTemplate.class);
        };
    }
}
